﻿package plugin.npcDialog.ui.panels.boss
{
    import cmd.*;
    import com.greensock.*;
    import com.sh.game.util.*;
    import flash.events.*;
    import flash.filters.*;
    import manager.*;
    import morn.core.handlers.*;
    import morn.core.utils.*;
    import pluginfw.nio.*;
    import uiresource.npcdialogs.*;
    import view.*;
    import view.uilt.*;

    public class BOSSCtrl6 extends MysdUI implements INpcDialogContent
    {
        private var tweenMax:TweenMax;
        private var _data:Object;

        public function BOSSCtrl6()
        {
            return;
        }// end function

        public function close() : void
        {
            if (this.parent)
            {
                this.parent.removeChild(this);
            }
            this.removeTween();
            return;
        }// end function

        public function show(param1:Object, param2:Object) : void
        {
            this._data = param1;
            this.updatebag();
            return;
        }// end function

        override protected function initializeView() : void
        {
            super.initializeView();
            label_jinru.addEventListener(MouseEvent.CLICK, this.clickHandler);
            goumai.clickHandler = new Handler(this.toGm);
            return;
        }// end function

        private function toGm() : void
        {
            DialogMgr.instance.open(AppDialog.SC_BUY, {storeId:137});
            return;
        }// end function

        protected function clickHandler(event:MouseEvent) : void
        {
            var _loc_6:Object = null;
            var _loc_2:* = ConfigDictionary.data.deliver[this._data.npcid][0];
            var _loc_3:* = _loc_2.level / 1000;
            if (_loc_3 > UserData.getUserData("rein"))
            {
                WarningManager.show(33, [_loc_3]);
                return;
            }
            var _loc_4:* = ItemUilt.getAllCount(240202020);
            if (ItemUilt.getAllCount(240202020) < 1)
            {
                _loc_6 = ConfigDictionary.data.item;
                WarningManager.show(31, [_loc_6[240202020].name]);
                return;
            }
            var _loc_5:* = new Output();
            new Output().writeVarInt(_loc_2.stageid, false);
            _loc_5.writeVarInt(_loc_2.x, false);
            _loc_5.writeVarInt(_loc_2.y, false);
            PluginManager.instance.sendToBufferServer("activity", CMDActivity.IntoBossInstance, _loc_5);
            return;
        }// end function

        public function update(param1:Object, param2:int = 0) : void
        {
            return;
        }// end function

        public function updatebag() : void
        {
            this.removeTween();
            var _loc_1:* = ItemUilt.getAllCount(240202020);
            numLabel.text = _loc_1.toString();
            if (_loc_1 >= 1)
            {
                numLabel.color = MColor.New61;
                goumai.visible = false;
            }
            else
            {
                numLabel.color = MColor.New56;
                goumai.visible = true;
                this.tweenMax = TweenMax.to(goumai, 1, {glowFilter:{color:16763904, alpha:1, blurX:10, blurY:10}, yoyo:true, repeat:int.MAX_VALUE, alpha:1});
            }
            return;
        }// end function

        public function removeTween() : void
        {
            if (this.tweenMax)
            {
                this.tweenMax.kill();
                this.tweenMax = null;
                ObjectUtils.clearFilter(goumai, GlowFilter);
            }
            return;
        }// end function

    }
}
